package com.lefeng.cockpit.datax.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.didiglobal.logi.security.common.PagingData;
import com.lefeng.cockpit.common.bean.dto.executor.ExecutorDTO;
import com.lefeng.cockpit.common.bean.vo.execute.ExecutorStateVO;
import com.lefeng.cockpit.common.bean.vo.execute.ExecutorVO;
import com.lefeng.cockpit.datax.dao.ExecutorDao;
import com.lefeng.cockpit.datax.service.ExecutorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author weifw_in
 */
@Service
@Transactional(readOnly = true)
@Slf4j
public class ExecutorServiceImpl implements ExecutorService {

    @Resource
    private ExecutorDao executorDao;

    @Override
    public PagingData<ExecutorVO> pagingExecutor(ExecutorDTO executorDTO) {
        IPage<ExecutorVO> dataSourcePOs = executorDao.selectPage(executorDTO);
        List<ExecutorVO> dataSourceVOS = dataSourcePOs.getRecords();
        return new PagingData<>(dataSourceVOS, dataSourcePOs);
    }

    @Override
    public ExecutorStateVO getExecutorState() {
        return executorDao.getExecutorState();
    }
}